<?php
class SendMailController extends AppController{
	var $name = 'SendMail';
	var $uses = array();
	var $helpers 	= array('Form');
	var $components = array('Email');
	var $view = 'Theme';
	var $layout = '';
	
	function index() {
//	$link = isset($this->params['url']['link'])? $this->params['url']['link'] : "";
	
//	if(isset($link)){$this->set('link', $link);}
		if(!empty($this->data)){
			$this->Email->to = $this->data['SendMail']['to'];
		   // $this->Email->bcc = $this->data['SendMail']['cc'];
		    $this->Email->subject = $this->data['SendMail']['subject'];
		    $this->Email->message = "<b>Name:</b>".$this->data['SendMail']['name']."(".$this->data['SendMail']['email'].")"."gửi cho bạn bài báo"."<br/>"."http://".$_SERVER['HTTP_HOST'].$this->data['SendMail']['link']." với lời nhắn:"."<br/>".$this->data['SendMail']['content'];
		    $this->Email->sendAs = 'html';
		    if($this->Email->send($this->Email->message)){
		   	echo"<script type='text/javascript'>
				
				window.history.back();
				alert('Bạn đã gửi thành công);
			</script>";		
			} else {
				$this->Session->setFlash(__('Không gửi được. Vui lòng thử lại', true), "flash_error");
			
		}
	}
}
}
?>